home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Programming / Complete Applications / 4D Programming / Random Tech Notes / Phone Format < prev   
Encoding:
Text File  |  1988-01-01  |  1.5 KB  |  39 lines  |  [TEXT/ttxt]

  1. ____________________________________________________________________
  2.  
  3. 4th Dimension Technical Notes
  4.  
  5. #11    Automatic formatting of phone number fields
  6.  
  7. Written by Dave Dell'Aquila    July 22, 1987
  8.  
  9. Published    August 1, 1987
  10. ____________________________________________________________________
  11.  
  12. Automatic formatting of phone number fields.
  13. ___________________________________________________________
  14.  
  15. This code shows how to format a phone number field so that it always appears as XXX-XXX-XXXX.  
  16. It can accept numbers entered as (xxx)xxx-xxxx, (xxx) xxx-xxxx,  xxx-xxx-xxxx, xxxxxxxxxx, and 
  17. xxxxxxx.  This will typically appear in the During phase of an Input Layout procedure.
  18.  
  19.       : (Modified(Phone))
  20.         Case of 
  21.           : (Length(Phone)=7)
  22.             Phone:=Substring(Phone;1;3)+"-"+Substring(Phone;4;4)
  23.           : (Length(Phone)=10)
  24.             Phone:=Substring(Phone;1;3)+"-"+Substring(Phone;4;3)+"-"+Substring(Phone;7;4)
  25.           : (Substring(Phone;1;1)=Char(40))   `Phone starts with a left paren
  26.             Case of 
  27.               : ((Substring(Phone;6;1)=Char(32))|(Substring(Phone;6;1)=Char(45))
  28.                    `case of space or dash after the close paren
  29.                 Phone:=Substring(Phone;2;3)+"-"+Substring(Phone;7;Length(Phone))
  30.               Else 
  31.                    `   no space after the close paren         
  32.                 Phone:=Substring(Phone;2;3)+"-"+Substring(Phone;6;Length(Phone))
  33.             End case 
  34.         End case 
  35.  
  36. #11:  Formatting Alpha fields    Page 1 of 1    
  37.  
  38.  
  39.